{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--BOOK_INFORMATION-->\n",
    "<img align=\"left\" style=\"padding-right:10px;\" src=\"figures/PHydro-cover-small.png\">\n",
    "*This is the Jupyter notebook version of the [Python in Hydrology](http://www.greenteapress.com/pythonhydro/pythonhydro.html) by Sat Kumar Tomer.*\n",
    "*Source code is available at [code.google.com](https://code.google.com/archive/p/python-in-hydrology/source).*\n",
    "\n",
    "*The book is available under the [GNU Free Documentation License](http://www.gnu.org/copyleft/fdl.html). If you have comments, corrections or suggestions, please send email to satkumartomer@gmail.com.*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--NAVIGATION-->\n",
    "< [Interpolation](05.09-Interpolation.ipynb) | [Contents](Index.ipynb) | [Uncertainty Intervals](05.11-Uncertainty-Intervals.ipynb) >"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5.9 插值\n",
    "\n",
    "做插值的方法有很多种。常用的方法是分段线性和非线性、样条函数和径向基函数。在本节中，我们将使用分段线性和径向基函数对数据进行插值。\n",
    "\n",
    "我们将首先生成几个具有指数关系的数据点。然后我们将使用`scipy.interpolate`库中的`interp1d`函数插值。这个函数返回一个对象，稍后可以使用该对象评估所需数据点处的拟合分段线性曲线。图5.15显示了拟合的分段多项式以及用于生成它的数据。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3XlclWX+//HXBwQRdxHKRMEFt2pyIdfcMiez0jIrjTLLcqqxbZp+U2PN0kwz33araUorsxKzrK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WAKf4x9Rzn3ICgFV1GpTznsFLKc54B/NrMVgJHgHudczuCV3XZlPKc7wFeNLO78XWjDA/lX/LM7A183X/1/eMkfwaiAJxzL+AbN+kPrAH2AzcE9P1D+M9OREQCLBy7j0RE5BQpFEREpJBCQURECikURESkkEJBREQKKRRERKSQQkFERAopFETKyMzO9a9rH2Nm1f37GJwV7LpEToUmr4kEgJn9Hd/yCtWAXOfcP4NcksgpUSiIBIB/XZ4MfPs2dHXOHQlySSKnRN1HIoFRD9/aUjXxXTGIhCRdKYgEgJlNxbcrWBOggXNuVJBLEjklYbdKqkh5M7NhQL5zbpKZRQJzzex859xnwa5N5GTpSkFERAppTEFERAopFEREpJBCQURECikURESkkEJBREQKKRRERKSQQkFERAopFEREpND/B1uaSqlcx4d1AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x26e79cc6b70>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from scipy.interpolate import interp1d\n",
    "# generate data\n",
    "x = np.linspace(0,1,5)\n",
    "y = np.exp(-x)\n",
    "f = interp1d(x,y)\n",
    "xnew = np.linspace(x.min(),x.max())\n",
    "ynew = f(xnew) #use interpolation function returned by `interp1d`\n",
    "# plot\n",
    "plt.plot(x,y,'ro',label='y')\n",
    "plt.plot(xnew, ynew, '-',label='ynew')\n",
    "plt.xlabel('x')\n",
    "plt.ylabel('y')\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<center>图5.15：插值曲线与测量数据</center>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`interp1d`不进行外推，如果我们想在输入数据范围外拟合数据，它将会产生一个错误。我们可以通过指定`bounds_error=None`参数抑制错误。在这个情况下，如果我们想在输入数据范围之外插值，它会给`nan`。实现输入数据范围之外的插值，我们可以使用`scipy.interpolate`库中的`Rbf`函数。记住在4.4节中，插值数据只在输入数据的位置范围之内。我们将使用`Rbf`函数实现输入数据范围之外的插值。我们使用`plt.imshow`来绘制二维图。二维插值如图5.16所示。从图中可以清晰地看出，它可以在输入数据范围之外插值。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARQAAAEKCAYAAADTrKqSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJztnX2wXWd1n591rq4kDLINlokl24ntIocId4iJCg4MNSTQ2E5iT2cosSdMIeOiCQ3pNECmtO5QxvknJUAmzDgk6tQhoROI6WSKJhU4JED5GAx2AwVkx0Y1BKtyIjC2kSXfe75W/zjX9jnrXTp736O9771H+j0zmrl7n3fv854Prbv3c9dar7k7QgjRBJ31noAQ4vRBAUUI0RgKKEKIxlBAEUI0hgKKEKIxFFCEEI3RWkAxs9vN7KiZffMkj5uZfcDMDpnZ183sJW3NRQixNrR5hfIh4Jopj18L7Fr5txf4YItzEUKsAa0FFHf/HPCDKUNuAP7ER9wFnGtmO9qajxCifTat43NfCDw0tn14Zd/DcaCZ7WV0FcOzz7KfeuELNj/9mFOd6btWucA20zGzHLV6svepzvsSj4vHDJNM62JMeI1xOx3j8Zjyd1/VMfmYztTHAbx47urnqXreLCHdKz77OI/RMWvDsQeOft/dz1/tcesZULJ3M32/3H0fsA9gz4u3+lfuvPjpxwY+LMYPw2mGTI4ZzFhusGDTvwCd5EvfqfjSLNjaePHsfeozCGPK96UXxvTCeZaSY5bDriVfmLoNcNw3T2yfGG6ZfDxsj86zWDnmxDCcd7Bl6uMAy8NNU7efHJTH9EOgWh5smvo4QH/YCWMWpj4O9YJZFojGMav+/n/q1b/3d5WDEtbzrzyH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1X63N2w/lMbS9teA2vMwszcAe4CrW53RdKbO18w6jCq/37RWE5pCnfd2E6PbnlcxuvL7vJld4e6PtTy3jDrzvQn4kLu/z8x+mlEe1hUeG9psDFb9f2yjXqHMU9p+nbliZq8BbgGud/flNZpbRtV8twFXAJ81s+8wunfev05itu734OPu3nP3bwP3Mwow60Gd+d4M3AHg7l8CtjIqHNyI1PpuT7BeQqhCFm0CHgQu5Rm59aIw5teYlLJ3bOC5XslI1u2ah/c2jP8s6ydl67y31wB/vPLzdkaX6Odt4Pl+AnjTys8/sfIf1Nbx+3AJJ5eyP8+klP1K5fnW64XUeKHXAQ+s/Ee8ZWXfrYx+w8Mosn8MOAR8BbhsA8/1r4B/AL628m//Rn5vw9h1Cyg131sD3g/cC3wDuHEjv7eM/rLzxZVg8zXgn63jXD8CPAz0GF2N3Az8KvCrY+/tbSuv5Rt1vgdKvRdCNMZGdShCiDlEAUUI0RgKKEKIxlBAEUI0hgKKEKIxFFBEK5jZxWb2bTN73sr2c1e217XSWrSLAopoBXd/CPgg8Nsru34b2Ofuf7d+sxJtozwU0Rpmtgj8b+B2RlXBV/qoClecpmzU4kBxGuDuPTP7TeCTjDJCFUxOc3TLI9rmWkbp3Ves90RE+yigiNYws58EXsuosOw3qprziPlHAUW0wkr3vA8C/9bdvwv8DvDe9Z2VaBsFFNEWbwa+6+6fWtn+feCFZraezaVEy+ivPEKIxtAVihCiMRRQhBCNoYAihGgMBRQhRGMooAghGkMBRQjRGAooQojG+P95P2TlQQV5rgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x26e7ca682e8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from scipy.interpolate import Rbf\n",
    "x = np.random.rand(5)\n",
    "y = np.random.rand(5)\n",
    "pet = 2+2*np.random.rand(5)\n",
    "\n",
    "rbfi = Rbf(x, y, pet) # radial basis function interpolation instance\n",
    "\n",
    "xi = np.linspace(0,1)\n",
    "yi = np.linspace(0,1)\n",
    "XI, YI = np.meshgrid(xi,yi) # gridded locations\n",
    "\n",
    "di = rbfi(XI, YI) # interpolated values\n",
    "\n",
    "plt.imshow(di, extent=(0,1,0,1), origin='lower')\n",
    "plt.scatter(x,y, color='k')\n",
    "plt.xlabel('X')\n",
    "plt.ylabel('Y')\n",
    "plt.axis((0,1,0,1))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<center>图5.16：二维插值</center>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
